package cn.no7player.service;

import cn.no7player.mapper.BaseMapper;
import cn.no7player.mapper.UserMapper;
import cn.no7player.model.UserEntity;
import cn.no7player.util.BaseUtil;
import cn.no7player.util.FastJsonConvert;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private BaseMapper baseMapper;

    public UserEntity findById(String jsonData){
        JSONObject jsonParams = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        UserEntity user=userMapper.findById(jsonParams.getString("id"));
        //user.setCreateTime(getCurrentTime());
        System.out.println(getCurrentTime());
        BaseUtil.generateKey(getCurrentTime());
        user.setId(BaseUtil.generateKey(getCurrentTime()));
        System.out.println(BaseUtil.generateKey(getCurrentTime()));
        return user;
    }
    public Date getCurrentTime(){
        return baseMapper.getCurrentTime();
    }
}
